﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ButtonApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void buttonBlue_Click(object sender, EventArgs e)
        {
            _oldPanelColor = panel1.BackColor;
            panel1.BackColor = Properties.Settings.Default.Blue;
        }

        private void buttonGreen_Click(object sender, EventArgs e)
        {
            _oldPanelColor = panel1.BackColor;
            panel1.BackColor = Properties.Settings.Default.Green;
        }

        private void buttonRed_Click(object sender, EventArgs e)
        {
            _oldPanelColor = panel1.BackColor;
            panel1.BackColor = Properties.Settings.Default.Red;
        }

        private void buttonWhite_Click(object sender, EventArgs e)
        {
            _oldPanelColor = panel1.BackColor;
            panel1.BackColor = Properties.Settings.Default.White;
        }

        private void buttonYellow_Click(object sender, EventArgs e)
        {
            _oldPanelColor = panel1.BackColor;
            panel1.BackColor = Properties.Settings.Default.Yellow;
        }

        private void buttonEnter(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            _oldColor = btn.BackColor;
            btn.BackColor = System.Drawing.Color.Red;

            switch (btn.Text)
            {
                case "Красный":
                    {
                        panel1.BackColor = Properties.Settings.Default.Red;
                        break;
                    }
                case "Голубой":
                    {
                        panel1.BackColor = Properties.Settings.Default.Blue;
                        break;
                    }
                case "Желтый":
                    {
                        panel1.BackColor = Properties.Settings.Default.Yellow;
                        break;
                    }
                case "Белый":
                    {
                        panel1.BackColor = Properties.Settings.Default.White;
                        break;
                    }
                case "Зеленый":
                    {
                        panel1.BackColor = Properties.Settings.Default.Green;
                        break;
                    }
            }
        }

        private void buttonLeave(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            btn.BackColor = _oldColor;
            panel1.BackColor =_oldPanelColor;
        }

        Color _oldColor;
        Color _oldPanelColor;
    }
}
